package daizuo.utils;

import daizuo.bean.User;

import java.io.BufferedWriter;
import java.io.FileWriter;
import java.io.IOException;

/**
 * @author cyt
 * @create 2020-02-25 14:41
 */
public class WriteInfo {
    public static void write(String flag, String con) {
        write(flag, con, false);
    }

    public static void write(String flag, String con, boolean append) {
        BufferedWriter bufferedWriter = null;
        // 定义
        try {
            bufferedWriter = new BufferedWriter(new FileWriter("e://" + flag + ".txt", append));
            bufferedWriter.write(con);
            bufferedWriter.newLine();
            bufferedWriter.flush();
            System.out.println("ok");
        } catch (IOException e) {
            e.printStackTrace();
        } finally {
            try {
                bufferedWriter.close();
            } catch (Exception e) {
            }
        }
    }
    public static void main(String[] args) throws IOException {
        User user = new User("180550207", "180550207");
        write("user", user.toString(), true);
    }
}
